﻿using Autofac;
using hello.csharp.common.Interfaces;
using hello.csharp.common.Interfaces.Storages;
using hello.csharp.storage.Db;
using hello.csharp.storage.Db.Mongo;
using hello.csharp.storage.Db.Sqlite;

namespace hello.csharp.storage.IoC
{
    public class StorageModule : Module
    {
        /// <summary>Override to add registrations to the container.</summary>
        /// <remarks>
        /// Other that the ContainerBuilder parameter is unique to this module.
        /// </remarks>
        /// <param name="builder">The builder through which components can be
        /// registered.</param>
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);
            builder.RegisterType<MongoManager>().As<INosqlDbManager>().SingleInstance();
            builder.RegisterType<DbInitialise>().As<IDbInitialise>().SingleInstance();
            builder.RegisterType<DbManager>().As<IDbManager>().SingleInstance();

            builder.RegisterType<ProductStorageWrite>().As<IProductStorageWrite>().SingleInstance();
            builder.RegisterType<ProductStorageRead>().As<IProductStorageRead>().SingleInstance();

            builder.RegisterType<UserStorageWrite>().As<IUserStorageWrite>().SingleInstance();
            builder.RegisterType<UserStorageRead>().As<IUserStorageRead>().SingleInstance();
            builder.RegisterType<UserSnackStorageWrite>().As<IUserSnackStorageWrite>().SingleInstance();
            builder.RegisterType<UserSnackStorageRead>().As<IUserSnackStorageRead>().SingleInstance();
        }
    }
}
